<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>生成器</title>
</head>
<body>
    <script>
       let infos = {
        name:"cq",
        friends:["cq","cqcq","cqq"],
        [Symbol.iterator]:function()
        {
            let index = 0;
            const iterator = {
                next:()=>
                {
                    if(index<this.friends.length)
                    {
                        return {done:false,value:this.friends[index++]};
                    }
                    else
                    {
                        return {done:true};
                    }
                }
            }
            return iterator;
        }
       }
        // const iterator = infos[Symbol.iterator]();
        // console.log(iterator.next().value);
        // console.log(iterator.next().value);
        // console.log(iterator.next().value);
        //可以调用for of
        for(name of infos)
        {
            console.log(name);
        }
    </script>
</body>
</html>